package org.cjlm.muaction.ds;

import org.cjlm.MLocator;
import org.cjlm.itf.ConnectionProvider;
import org.cjlm.ui.pub.MAbstraction;

import java.awt.event.ActionEvent;
import java.sql.Connection;

public class BillTableInitAction extends MAbstraction {
    public BillTableInitAction(String title) {
        super(title);
    }

    @Override
    public void doAction(ActionEvent e) throws Exception {
        Connection conn = MLocator.getInstance(ConnectionProvider.class).getConnection();
        if(conn != null){
                DbInitializer.initialize(conn);
                showHintDialog("提示", "初始化成功");
        }else{
            throw new Exception("数据库初始化失败: 请检查是否设置默认数据源");
        }
    }
}
